Telegram Group & Telegram Channel
🎓 Задача по Python #46

Описание:

Напишите программу, которая проверит, что число является совершенным.
Совершенное число - натуральное число, равное сумме всех своих собственных делителей.
Например, число 6 равно сумме своих собственных делителей 1 + 2 + 3.

Примеры совершенных чисел:

6, 28, 496, 8128

Решение:

def get_divisors(num):
divisors = []
for i in range(1, num):
if num % i == 0:
divisors.append(i)
return divisors

def perfect_num(num):
divisors = get_divisors(num)
return num == sum(divisors)

print(perfect_num(6))
print(perfect_num(28))
print(perfect_num(496))
print(perfect_num(8128))

Свой вариант решения в комментарии 💬

#задачи



tg-me.com/pythonturboru/559
Create:
Last Update:

🎓 Задача по Python #46

Описание:

Напишите программу, которая проверит, что число является совершенным.
Совершенное число - натуральное число, равное сумме всех своих собственных делителей.
Например, число 6 равно сумме своих собственных делителей 1 + 2 + 3.

Примеры совершенных чисел:

6, 28, 496, 8128

Решение:

def get_divisors(num):
divisors = []
for i in range(1, num):
if num % i == 0:
divisors.append(i)
return divisors

def perfect_num(num):
divisors = get_divisors(num)
return num == sum(divisors)

print(perfect_num(6))
print(perfect_num(28))
print(perfect_num(496))
print(perfect_num(8128))

Свой вариант решения в комментарии 💬

#задачи

BY Python Turbo. Уютное сообщество Python разработчиков.




Share with your friend now:
tg-me.com/pythonturboru/559

View MORE
Open in Telegram


Python Turbo Уютное сообщество Python разработчиков Telegram | DID YOU KNOW?

Date: |

The STAR Market, as is implied by the name, is heavily geared toward smaller innovative tech companies, in particular those engaged in strategically important fields, such as biopharmaceuticals, 5G technology, semiconductors, and new energy. The STAR Market currently has 340 listed securities. The STAR Market is seen as important for China’s high-tech and emerging industries, providing a space for smaller companies to raise capital in China. This is especially significant for technology companies that may be viewed with suspicion on overseas stock exchanges.

NEWS: Telegram supports Facetime video calls NOW!

Secure video calling is in high demand. As an alternative to Zoom, many people are using end-to-end encrypted apps such as WhatsApp, FaceTime or Signal to speak to friends and family face-to-face since coronavirus lockdowns started to take place across the world. There’s another option—secure communications app Telegram just added video calling to its feature set, available on both iOS and Android. The new feature is also super secure—like Signal and WhatsApp and unlike Zoom (yet), video calls will be end-to-end encrypted.

Python Turbo Уютное сообщество Python разработчиков from vn


Telegram Python Turbo. Уютное сообщество Python разработчиков.
FROM USA